part of '../repository.dart';

const _kGooglePlayOneTimePurchasedItemRevokedKey = 'revoked';

const _kGooglePlayOneTimePurchasedItemTypeValue = 'one_time_purchased_item';

class _GooglePlayOneTimePurchasedItemDto extends Equatable implements _GooglePlayPurchasedItemDto {
  const _GooglePlayOneTimePurchasedItemDto._internal({
    required this.purchaseItemSku,
    required this.purchaseToken,
    required this.revoked,
  });

  @override
  final String purchaseItemSku;

  @override
  final String purchaseToken;

  final bool revoked;

  @override
  List<Object?> get props {
    return [
      purchaseItemSku,
      purchaseToken,
      revoked,
    ];
  }

  factory _GooglePlayOneTimePurchasedItemDto.fromJson(Map<String, dynamic> json) {
    return _GooglePlayOneTimePurchasedItemDto._internal(
      purchaseItemSku: json[_kGooglePlayPurchasedItemPurchaseItemSkuKey],
      purchaseToken: json[_kGooglePlayPurchasedItemPurchaseTokenKey],
      revoked: json[_kGooglePlayOneTimePurchasedItemRevokedKey],
    );
  }

  @override
  GooglePlayOneTimePurchasedItem toEntity() {
    return GooglePlayOneTimePurchasedItem(
      purchaseItemSku: purchaseItemSku,
      purchaseToken: purchaseToken,
      revoked: revoked,
    );
  }
}
